<template>
  <div class="home">
    <a-row class="comm-main" type="flex" justify="center" :gutter="5">
      <a-col class="comm-left list" :xs="20" :sm="14" :md="13" :lg="14" :xl="13">
        <a-card class="box-card" shadow="hover">
          <a-list header="最新日志" itemLayout="vertical">
            <a-list-item v-for="(item, index) in myList" :key="index">
              <div class="list-title" @click="read(item.id)">{{item.title}}</div>
              <div class="list-icon">
                <span>
                  <a-icon type="calendar" />
                  &nbsp;{{item.addTime}}
                </span>
                <span>
                  <a-icon type="folder" />
                  &nbsp;{{item.typeName}}
                </span>
                <span>
                  <a-icon type="fire" />
                  &nbsp;{{item.view_count}}
                </span>
              </div>
              <div class="list-img">
                <img v-lazy="item.article_url" />
              </div>
              <div class="list-context">{{item.introduce}}</div>
              <div class="preview">
                <div class="preview-icon">
                  <a-icon type="read" />
                </div>
                <div @click="read(item.id)" class="preview-content">查看全文 ></div>
              </div>
            </a-list-item>
          </a-list>
        </a-card>
      </a-col>
      <a-col class="comm-left author" :xs="0" :sm="6" :md="5" :lg="5" :xl="5">
        <a-affix>
          <a-card class="box-card" shadow="hover">
            <Author />
          </a-card>
          <a-card class="advert" shadow="hover">
            <Advert />
          </a-card>
        </a-affix>
      </a-col>
    </a-row>
    <Footer />
  </div>
</template>

<script>
import Author from "../Author/index";
import Advert from "../Advert/index";
import Footer from "../Footer/index";
export default {
  data() {
    return {
      myList: [],
    };
  },
  created() {
    this.getArticleList();
  },
  methods: {
    async getArticleList() {
      let { data } = await this.$http({
        method: "GET",
        url: "/default/getArticleList",
      });
      this.myList = data.data;
    },
    read(id) {
      this.$router.push({
        path: "/detailed/" + id,
      });
    },
  },
  components: {
    Author,
    Advert,
    Footer,
  },
};
</script>

<style lang="less">
.home {
  overflow: hidden;
  .list {
    animation: fade-in 0.5s ease;
    .ant-card {
      background: rgba(255, 255, 255, 0.9);
    }
  }
  .author {
    .ant-card {
      background: rgba(255, 255, 255, 0.8);
    }
  }
}
@keyframes fade-in {
  0% {
    opacity: 0;
  } /*初始状态 透明度为0*/
  40% {
    opacity: 0;
  } /*过渡状态 透明度为0*/
  100% {
    opacity: 1;
  } /*结束状态 透明度为1*/
}
.ant-list {
  .ant-list-header {
    font-size: 1.1rem;
    font-weight: bold;
  }
}
.list-title {
  font-size: 1.3rem;
  color: #1e90ff;
  padding: 0 0.5rem;
  cursor: pointer;
  transition: color 0.5s;
  &&:hover {
    color: #112c69;
  }
}

.list-icon {
  user-select: none;
}
.list-context {
  padding: 0.5rem;
  font-size: 1rem;
  color: #999 !important;
}
.list-icon {
  padding: 0.5rem 0;
  color: #aaa;
  span {
    display: inline-block;
    padding: 0 5px;
    i {
      text-indent: 3px;
    }
  }
}
.list-img {
  img {
    width: 100%;
    max-width: 100%;
  }
}
.preview {
  margin-top: 1em;
  display: flex;
  justify-content: flex-end;
  .preview-content {
    margin-right: 20px;
    color: #1890ff;
    cursor: pointer;
  }
  .preview-icon {
    margin-right: 0.5em;
    color: #bbbbbb;
  }
}
</style>